/**
 * @(#)FileUtil.java, 2013-2-12. Copyright 2013 RENREN, Inc. All rights
 *                    reserved. RENREN PROPRIETARY/CONFIDENTIAL. Use is subject
 *                    to license terms.
 */
package com.wennimei.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author shichen.feng@renren-inc.com
 */
public class FileUtil {

    public static void processFile(String path, FileProcessor procesor) {
        try {
            InputStreamReader read = new InputStreamReader(new FileInputStream(
                    new File(path)));
            BufferedReader bufferedReader = new BufferedReader(read);
            String line = null;
            while ((line = bufferedReader.readLine()) != null) {
                try {
                    procesor.process(line);
                } catch (Exception e) {
                    e.printStackTrace();
                    continue;
                }
            }
            read.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
